package com.lfy.kcat.content.controller.ai.controller;

import com.lfy.kcat.content.biz.AuthCheckService;
import com.lfy.kcat.content.vo.ManualAuthTaskVo;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.dto.DramaAuthCompleteDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthCheckController {
    @Autowired
    private  AuthCheckService authCheckService;
    /**
     * 获取短剧AI审核状态
     * @param dramaId
     * @return     * @return
     */
    @GetMapping("/dramas/authcheck/{dramaId}")
    public R getAiCheckStatus(@PathVariable("dramaId") Long dramaId){
        //TODO 获取这个短剧的AI审核结果
        // (让流程框架，获取到当前短剧对应的审核流程目前的所有变量名和值)
        Integer status = authCheckService.getAiCheckStatus(dramaId);

        return R.ok("success",status);
    }

    /**
     * 人工审核
     */
    @PostMapping("/dramas/authcheck")
    public R manualCheckTask(@RequestBody ManualAuthTaskVo manualAuthTaskVo,
                             @RequestHeader("authorization") String authHeader) {
        //springdoc ==> openapi规范的 接口描述.json  ==> apifox/postman都可以用

        //TODO 执行人工审核流程
        authCheckService.saveManualAuthData(manualAuthTaskVo,authHeader);
        return R.ok();
    }


    /**
     * 更新审核数据库
     * @return
     */
    @PutMapping("/dramas/updateauthdb")
    public R updateDramaAuthStatus(@RequestBody DramaAuthCompleteDTO dto){
        authCheckService.completeAuthUpdateDb(dto);
        return R.ok();
    }
}
